<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico" >
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/html5shiv.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/action.js"></script>

    <title>新增心意卡</title>
    <style>
        #picInput>input{
            display: block;
            margin: 10px;
        }

    </style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 心意卡管理 <span class="c-gray en">&gt;</span> 新增心意卡
</nav>
<div class="page-container">
    <form class="form form-horizontal" action="{:U('save')}" method="post" onsubmit="return ac_from();" enctype="multipart/form-data">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>主题：</label>
            <div class="formControls col-xs-8 col-sm-3">
                <input type="text" class="input-text" placeholder="主题名称" name="name" id="name" value="<?php echo $brand_info['name']; ?>">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>卡片图片：</label>
            <div class="formControls col-xs-8 col-sm-3" id="picInput">
                <if condition="$brand_info['id'] neq ''">
                        <foreach name="list" item="vo" >
                            <br>
                            <img id='output_{$vo.id}' src="__DATA__/UploadFiles/{$vo.brand_photo}" width="80px" height="50px">
                            <br><br>
                            <a class="btn btn-default radius" id="span_output" href="{:U('del_brand_image')}?id={$vo.id}">移除</a>
                        </foreach>
                    <else />
                        <input type="file" id="output_file"  name='myfile[]' onchange='openFile(event,"output")'>
                        <img id='output' >
                </if>

            </div>
            <a class="btn btn-default radius" onclick="addPic1()">增加</a>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>状态：</label>
            <div class="formControls col-xs-8 col-sm-3" >
                <input type="radio" name="if_show" value="1" <?php echo $brand_info['if_show']==1 ? 'checked="checked"' : null?>>立即上架
                <input type="radio" name="if_show" value="0" <?php echo $brand_info['if_show']==0 ? 'checked="checked"' : null?>>立即下架
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>积分可用：</label>
            <div class="formControls col-xs-8 col-sm-3" >
                <input type="radio" name="type" value="1" <?php echo $brand_info['type']==1 ? 'checked="checked"' : null?>>不能积分兑换且购买无积分
                <input type="radio" name="type" value="0" <?php echo $brand_info['type']==0 ? 'checked="checked"' : null?>>可用
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">选择关联的产品：</label>
            <div class="formControls col-xs-8 col-sm-3" style="width: 60%">
                <br> <br>
                <table>
                    <volist name="goods_list" id="vo">
                    <tr style="border-bottom: 2px solid #DBDDDB">
                        <td style="visibility: hidden;position: absolute">
                            <input type="checkbox" id="input_{$vo.id}" name="goods_name[]" value="{$vo.id}" <?php if(strpos($brand_info['product_ids'], $vo['id']) !== false){ echo 'checked'; } ?>>
                        </td>
                        <td>
                            <img src="__DATA__/{$vo.photo_x}" alt="" width="70px" height="70px" style="padding: 6px 0px 6px 0px">
                        </td>
                        <td>{$vo.name}</td>
                        <td>{$vo.price}</td>
                        <td>{$vo.num}盒</td>
                        <td id="text_{$vo.id}">
                            <?php if(strpos($brand_info['product_ids'], $vo['id']) !== false){ echo '<font color="green">已选择</font>'; } else { echo '---'; } ?>
                        </td>
                        <td id="tt_{$vo.id}" >
                            <?php if(strpos($brand_info['product_ids'], $vo['id']) !== false){ ?>
                                <span id="{$vo.id}" style="color: red;cursor: pointer" onclick='remove_product(this.id)'>移除</span>
                                <?php  } else { ?>
                                <span id="{$vo.id}" style="color: red;cursor: pointer" onclick='test(this.id)'>添加</span>
                                <?php } ?>
                            </if>
                        </td>
                    </tr>
                    </volist>
                </table>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" name="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                <input id="reset" class="btn btn-default radius" type="reset" name="reset" value="&nbsp;&nbsp;取消&nbsp;&nbsp;">
                <input type="hidden" name="id" id="id" value="<?php echo $brand_info['id']; ?>">
            </div>
        </div>
    </form>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__PUBLIC__/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/lib/laypage/1.2/laypage.js"></script>

<script>
    function ac_from(){
        var name=document.getElementById('name').value;
        if(!name){
            alert('请输入登录账号！');
            return false;
        }

        if(!<?php echo $id; ?>){
            var password=document.getElementById('password').value;
            if(password.length<6){
                alert('密码长度不能少于6');
                return false;
            }
        }

    }
</script>
<!--添加卡片图片-->
<script>
    function addPic1(){
        var timestamp = Date.parse(new Date())/ 1000;
        var funsff = "openFile(event,'output_"+timestamp+"')";
        var remove_fun = "remove_yuansu('input_"+timestamp+"','output_"+timestamp+"','span_"+timestamp+"')";
        var html= '<input id="input_'+timestamp+'"  name="myfile[]" onchange="'+funsff+'" type="file" /> <img id="output_'+timestamp+'" style="margin-bottom: 3px;"><br><span class="btn btn-default radius" id="span_'+timestamp+'" onclick="'+remove_fun+'">移除</span>' ;
        $("#picInput").append(html);
    }
    function remove_yuansu(input_obj,img_obj,span_obj){
        $("#"+input_obj).remove();
        $("#"+img_obj).remove();
        $("#"+span_obj).remove();
    }
    var openFile = function(event,obj) {
        var input = event.target;
        var reader = new FileReader();
        $("#"+obj).attr("width","100px");
        $("#"+obj).attr("height","80px");
        reader.onload = function(){
            var dataURL = reader.result;
            var output = document.getElementById(obj);
            output.src = dataURL;
        };
        reader.readAsDataURL(input.files[0]);
    };
</script>
<!--选择产品-->
<script>
    function test(id) {
        $("#input_"+id).prop("checked","true");
        $("#text_"+id).html("<span style='color: green'>已选择</span>");
        $("#tt_"+id).html('<span id="'+id+'" style="color: lightgrey;cursor: pointer" onclick="remove_product(id)">移除</span>');

    }
    function remove_product(id) {
        $("#input_"+id).removeAttr("checked",false);
        $("#text_"+id).html("<span>---</span>");
        $("#tt_"+id).html('<span id="'+id+'" style="color:red;cursor: pointer" onclick="test(id)">添加</span>');
    }
</script>
</body>
</html>
